package net.dengzixu.java.homework.period9;

public class Period9Homework2 {
    public static void main(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (isPrime(i)) {
                System.out.printf("%2d ", i);
                count++;
            }
            if (count % 10 == 0) {
                System.out.println();
            }
        }
    }

    public static boolean isPrime(int num) {
        // 1 不是质数 直接干掉
        if (num < 2) {
            return false;
        }

        // 直接对半砍
        for (int i = 2; i <= num / 2; i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}
